|
|
 |
|
|
|
|
With pixels(X, Y)
If factor < 0 Then ' Make the color darker. .rgbRed = (1 + factor) * .rgbRed
.rgbGreen = (1 + factor) * .rgbGreen
.rgbBlue = (1 + factor) * .rgbBlue
Else
' Make the color brighter. .rgbRed = .rgbRed + factor * (255 - .rgbRed)
.rgbGreen = .rgbGreen + factor * (255 - .rgbGreen)
.rgbBlue = .rgbBlue + factor * (255 - .rgbBlue)
End If
End With |
|
|
|
|
|
|
|
|
Unlike image complements, images with adjusted brightness are not invertible. The reason is some color components may map to fractional values when they are adjusted. Since the color components are converted into byte values, some of the color information is lost. Applying a reverse adjustment cannot reproduce the missing information exactly. |
|
|
|
|
|
|
|
|
For example, suppose you increase an image's brightness by 99 percent. Many of the pixel values become white. If you now decrease the pixels' component values by 50 percent, trying to recover the original image, the result is mostly gray. |
|
|
|
|
|
|
|
|
Program Bright adjusts a pixel's brightness by changing its red, green, and blue color components by similar amounts. You can change an image's color balance by adjusting the pixels' components by different amounts. For example, to decrease the amount of blue in an image, you could multiply the blue component of each pixel by 0.5. |
|
|
|
|
|
|
|
|
Example program ColorBal, shown in Figure 6.4, lets you use scroll bars to specify the amount by which it should adjust each pixel's red, green, and blue components. The result is more striking in color than it is in the grayscale image shown in Figure 6.4. |
|
|
|
|
|
|
|
|
The only significant differences between this program and the previous programs are in the following statements that set a new pixel's color component values. The values r_factor, g_factor, and b_factor represent the amount by which the red, green, and blue components should be adjusted. |
|
|
|
 |
|
|
|
|
With pixels(X, Y)
If r_factor < 0 Then
.rgbRed = (1 + r_factor) * .rgbRed
Else
.rgbRed = .rgbRed + r_factor * (255 - .rgbRed)
End If
If g_factor < 0 Then
.rgbGreen = (1 + g_factor) * .rgbGreen
Else
.rgbGreen = .rgbGreen + g_factor * (255 - .rgbGreen)
End If |
|
|
|
|
|